package com.dhl.observer;

/**
 * @title: WeatherData
 * @Author danghailiang
 * @Date: 2022/8/20 17:29
 * @Version 1.0
 */
// 天气预报
public class WeatherData {
    /**
     * 湿度
     */
    private int temperature;
    /**
     * 湿度
     */
    private int humidity;
    /**
     * 压力
     */
    private int pressure;

    private CurrentConditions currentConditions;

    public WeatherData(CurrentConditions currentConditions) {
        this.currentConditions = currentConditions;
    }

    /**
     * 温度
     */
    public int getTemperature() {
        return temperature;
    }

    /**
     * 湿度
     */
    public int getHumidity() {
        return humidity;
    }

    /**
     * 压力
     */
    public int getPressure() {
        return pressure;
    }

    /**
     * 通知进行修改天气
     */
    private void dataChange() {
        currentConditions.update(temperature, humidity, pressure);
    }

    /**
     * 修改天气
     * @param temperature 温度
     * @param humidity 湿度
     * @param pressure 气压
     */
    public void setData(int temperature, int humidity, int pressure) {
        this.temperature = temperature;
        this.humidity = humidity;
        this.pressure = pressure;
        dataChange();
    }
}
